#include "mnemonic.hpp"

boost::array<Mnemonic, NUMBER_OF_MNEMONICS> all_mnemonics()
{
	boost::array<Mnemonic, NUMBER_OF_MNEMONICS> ret;
	for (int i(0); i < NUMBER_OF_MNEMONICS ; ++i) {
		ret[i] = static_cast<Mnemonic>(i);
	}

	return ret;
}

bool has_return(Mnemonic mnem)
{
	switch(mnem)
	{
	case NOOP: return false;
	case ADD: return true;
	case SUB: return true;
	case MULT: return true;
	case DIV: return true;
	case MIN: return true;
	case MAX: return true;
	case AND: return true;
	case MOD: return true;
	case OR: return true;
	case XOR: return true;
	case LSHIFT: return true;
	case RSHIFT: return true;
	case EQ: return true;
	case NEQ: return true;
	case LT: return true;
	case LTE: return true;
	case GT: return true;
	case GTE: return true;
	case IF: return false;
	case GETI: return true;
	case GETO: return true;
	case GETA: return true;
	case GETB: return true;
	case GETR: return true;
	case BEFORE: return true;
	case AFTER: return true;
	case CREATE_BEFORE: return true;
	case CREATE_AFTER: return true;
	case REMOVE: return false;
	case RAND: return true;
	case READ: return true;
	case EXIT: return false;
	case NUMBER_OF_MNEMONICS: // just to avoid a warning
		break;
	}

	assert(false);
	return "";
}


std::string show(Mnemonic mnem)
{
	switch(mnem)
	{
	case NOOP: return "NOOP";
	case ADD: return "ADD";
	case SUB: return "SUB";
	case MULT: return "MULT";
	case DIV: return "DIV";
	case MIN: return "MIN";
	case MAX: return "MAX";
	case MOD: return "MOD";
	case AND: return "AND";
	case OR: return "OR";
	case XOR: return "XOR";
	case LSHIFT: return "LSHIFT";
	case RSHIFT: return "RSHIFT";
	case EQ: return "EQ";
	case NEQ: return "NEQ";
	case LT: return "LT";
	case LTE: return "LTE";
	case GT: return "JGT";
	case GTE: return "GTE";
	case IF: return "IF";
	case GETI: return "GETI";
	case GETO: return "GETO";
	case GETA: return "GETA";
	case GETB: return "GETB";
	case GETR: return "GETR";
	case BEFORE: return "BEFORE";
	case AFTER: return "AFTER";
	case CREATE_BEFORE: return "CREATE_BEFORE";
	case CREATE_AFTER: return "CREATE_AFTER";
	case REMOVE: return "REMOVE";
	case RAND: return "RAND";
	case READ: return "READ";
	case EXIT: return "EXIT";
	case NUMBER_OF_MNEMONICS: // just to avoid a warning
		break;
	}

	assert(false);
	return "";
}


